package com.exam.hibuy.mapper;

import com.exam.hibuy.model.Resources;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * Created by admin on 2017/12/1.
 */
@Mapper
public interface ResourcesMapper {
    @Select("select * from resources")
    List<Resources> queryAll();

    @Select("select r.* from resources r \n" +
            "LEFT JOIN role_resources rr ON r.id = rr.resourcesId \n" +
            "LEFT JOIN user_role ur ON ur.roleId = rr.roleId \n" +
            "WHERE ur.userId = #{userId} ")
    List<Resources> loadUserResources(Map<String, Object> map);
}
